package com.app.micaihu.view.newsdetail;

import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.fragment.app.FragmentTransaction;

import com.android.volley.VolleyError;
import com.app.micaihu.R;
import com.app.micaihu.ad.AdConfig;
import com.app.micaihu.app.AppApplication;
import com.app.micaihu.base.BaseOldActivity;
import com.app.micaihu.base.bean.DataBean;
import com.app.micaihu.bean.comment.NewsComment;
import com.app.micaihu.bean.news.NewsEntity;
import com.app.micaihu.bean.news.VideoContent;
import com.app.micaihu.configure.Config;
import com.app.micaihu.configure.TypeConstant;
import com.app.micaihu.configure.URIContant;
import com.app.micaihu.custom.components.ParamMap;
import com.app.micaihu.custom.view.AttentionView;
import com.app.micaihu.custom.view.CustomImageView;
import com.app.micaihu.custom.view.dialog.ReportDialog;
import com.app.micaihu.custom.view.listivew.CommentListView;
import com.app.micaihu.custom.view.web.CustomWebView;
import com.app.micaihu.db.NewsDBUtil;
import com.app.micaihu.listener.CommentListener;
import com.app.micaihu.listener.HttpListener;
import com.app.micaihu.manager.UserInforManager;
import com.app.micaihu.utils.AppShareUtils;
import com.app.micaihu.utils.CollectUtils;
import com.app.micaihu.utils.CommentUtils;
import com.app.micaihu.utils.DialogUtils;
import com.app.micaihu.utils.HttpUtils;
import com.app.micaihu.utils.ImageLoadUtils;
import com.app.micaihu.utils.InteractiveUtils;
import com.app.micaihu.utils.StatServiceUtils;
import com.app.micaihu.videoplayer.JCMediaManager;
import com.app.micaihu.videoplayer.JCScreenSwitchUtils;
import com.app.micaihu.videoplayer.JCVideoPlayer;
import com.app.micaihu.videoplayer.JCVideoPlayerManager;
import com.app.micaihu.videoplayer.JCVideoPlayerStandard;
import com.app.micaihu.view.army.activity.ArmyDetailActivity;
import com.app.micaihu.view.army.activity.ArmyMedalListActivity;
import com.app.micaihu.view.main.game.GameDetailActivity;
import com.app.micaihu.view.newsdetail.adapter.VideoAboutAdapter;
import com.app.micaihu.view.newsdetail.fragment.VideoShowFragment;
import com.app.micaihu.view.user.userinfo.activity.MyHomepageDynamicActivity;
import com.app.utils.biz.Biz;
import com.app.utils.util.StringUtils;
import com.app.utils.util.ToastUtils;
import com.app.utils.util.ViewSizeUtils;
import com.app.utils.util.image.LoadImageUtils;
import com.app.utils.util.osutils.StatusBarUtils;
import com.app.widget.LoadView;
import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.LogUtils;
import com.google.gson.reflect.TypeToken;
import com.tencent.smtt.export.external.interfaces.IX5WebChromeClient;
import com.tencent.smtt.export.external.interfaces.SslError;
import com.tencent.smtt.export.external.interfaces.SslErrorHandler;
import com.tencent.smtt.sdk.DownloadListener;
import com.tencent.smtt.sdk.WebChromeClient;
import com.tencent.smtt.sdk.WebSettings;
import com.tencent.smtt.sdk.WebView;
import com.tencent.smtt.sdk.WebViewClient;
import com.umeng.socialize.UMShareAPI;

import java.util.HashMap;
import java.util.List;

/**
 * 视频详情页面
 * Created by linkai on 2016/8/2.
 */
public class VideoDetailActivity extends BaseOldActivity implements View.OnClickListener, DialogUtils.OnDialogBtnClickListener {

    /************
     * 页面控件 start
     ****************/
    private CustomWebView mWebview;//webview播放器
    private CommentListView mCommentListview;//评论listview
    private LoadView mNewsLoadView;//文章加载提示
    private TextView mCommentSum;//评论总数
    private TextView mShareSum;//分享总数
    private ImageView mCollectView;//收藏
    private TextView mPraiseView;//点赞总数
    private TextView mTimeView;//时间
    private TextView mPlayCount;//播放总数
    private TextView mTitleView;//标题
    public CustomImageView mUserHead;//用户头像
    public ImageView ivHonourPic;//用户头像
    public TextView mUserName;//用户昵称
    public TextView tvArmyGroupInfo;//用户昵称
    public CustomImageView mUserRankImg;//用户军衔图片
    public TextView mUserRankText;//用户军衔名称
    private ListView mAboutListView;//相关新闻
    private ListView mSetNumListView;//视频选集列表
    private View mVideoLoad;//加载等待提示
    private View mBottomLayoutView;//下方菜单
    private TextView mSetNumTitle;//选集名称
    private TextView mSetNumUpdate;//选集更新日期
    private View mMoreVideo;//查看更多
    private View mMoreVideoLayout;//更多视频模块
    private AttentionView attView;//关注按钮
    private View viewFullScreen;
    private FrameLayout laudContainer;
    private RelativeLayout rlGame;

    private View mPlayLayout;//视频播放模块
    private View mPlayerWeb;//web播放器
    private JCVideoPlayerStandard mPlayerJcvideo;//视频播放器
    /**************
     * 页面数据 start
     ************/
    private String newsId;//视频文章id
    private String pageSourceType;//来源类型 1正常列表 2相关列表 3网页 4push
    private VideoContent mNewsContent;//视频详情数据
    private NewsEntity.GameInfo gameInfo;// 不等于 null  代表知识列表跳转过来的 视频游戏
    private Boolean islandport = true;//true表示此时是竖屏，false表示此时横屏。

    //传入的视频数据(用于接着放)
    private static String URL;
    private static Object[] OBJECTS;
    private static int CURRENT_STATE = -1;

    /********
     * 页面工具
     ************/
    private CommentListener mCommentListener;//评论监听
    private AppShareUtils mShareUtils;//分享工具
    private ReportDialog reportDialog;
    private FrameLayout videoView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        isInit = false;
        getIntentData();
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);
        StatusBarUtils.setupStatusBarView(this, R.color.common_bg_color_8, R.color.common_bg_color_8);
        //改变通知栏顶部
        setTitleShow(false);
        //初始化页面控件
        initView();
        //释放掉JC
        JCVideoPlayer.releaseAllVideos();
        //加载页面数据
        loadData(true);
        //查询本地收藏
        querySaveNews();
    }

    /************** 页面初始化 start *******************/

    /**
     * 初始化页面控件
     */
    private void initView() {
        mCommentListview = (CommentListView) findViewById(R.id.prlv_listview);
        mNewsLoadView = (LoadView) findViewById(R.id.lv_loadview);
        mCommentSum = (TextView) findViewById(R.id.tv_commentSum);
        mShareSum = (TextView) findViewById(R.id.tv_shareSum);
        mCollectView = (ImageView) findViewById(R.id.iv_collect);
        mPlayerJcvideo = (JCVideoPlayerStandard) findViewById(R.id.vps_videoplayer);
        mPlayLayout = findViewById(R.id.fl_paly_layout);
        View commentView = findViewById(R.id.tv_comment);
        ViewGroup.LayoutParams params = commentView.getLayoutParams();
        params.width = ViewSizeUtils.getWidthPixels() * 3 / 7;
        View commentLayout = findViewById(R.id.newsDetail_comment_layout);
        mBottomLayoutView = findViewById(R.id.bottom_menu_layout);
        View share = findViewById(R.id.iv_share);
        findViewById(R.id.iv_report).setOnClickListener(this);
        share.setOnClickListener(this);
        commentView.setOnClickListener(this);
        commentLayout.setOnClickListener(this);
        mCollectView.setOnClickListener(this);
        mCommentSum.setOnClickListener(this);
        mNewsLoadView.setErrorPageClickListener(this);

        //添加评论listview头部
        View aboutListHead = getLayoutInflater().inflate(R.layout.layout_comment_video_head, null);
        ((TextView) aboutListHead.findViewById(android.R.id.text1)).setText("相关视频");
        mUserHead = (CustomImageView) aboutListHead.findViewById(R.id.video_usericon);
        ivHonourPic = aboutListHead.findViewById(R.id.ivHonourPic);
        tvArmyGroupInfo = aboutListHead.findViewById(R.id.tvArmyGroupInfo);
        mUserName = (TextView) aboutListHead.findViewById(R.id.video_username);
        mUserRankImg = (CustomImageView) aboutListHead.findViewById(R.id.video_rank);
        mUserRankText = (TextView) aboutListHead.findViewById(R.id.video_rank_name);
        mPraiseView = (TextView) aboutListHead.findViewById(R.id.tv_zan);
        mTimeView = (TextView) aboutListHead.findViewById(R.id.tv_time);
        mPlayCount = (TextView) aboutListHead.findViewById(R.id.tv_playcount);
        mTitleView = (TextView) aboutListHead.findViewById(R.id.tv_title);
        mAboutListView = (ListView) aboutListHead.findViewById(R.id.lv_aboutlist);
        mSetNumListView = (ListView) aboutListHead.findViewById(R.id.lv_collectlist);
        mSetNumTitle = (TextView) aboutListHead.findViewById(R.id.tv_setnum_title);
        mSetNumUpdate = (TextView) aboutListHead.findViewById(R.id.tv_setnum_update);
        mMoreVideo = aboutListHead.findViewById(R.id.tv_read_all);

        attView = (AttentionView) aboutListHead.findViewById(R.id.attention);

        laudContainer = (FrameLayout) aboutListHead.findViewById(R.id.fl_laud_container);

        mUserHead.setOnClickListener(this);
        mUserName.setOnClickListener(this);
        laudContainer.setOnClickListener(this);
        mMoreVideo.setOnClickListener(this);

        ivHonourPic.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mNewsContent != null && !com.blankj.utilcode.util.StringUtils.isEmpty(mNewsContent.getAuthorId())) {
                    Intent intent = new Intent(VideoDetailActivity.this, ArmyMedalListActivity.class);
                    intent.putExtra(Config.Extra.toUid, mNewsContent.getAuthorId());
                    ActivityUtils.startActivity(intent);
                }
            }
        });
        tvArmyGroupInfo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mNewsContent != null
                        && !com.blankj.utilcode.util.StringUtils.isEmpty(mNewsContent.getAuthorId())
                        && !com.blankj.utilcode.util.StringUtils.isEmpty(mNewsContent.getGid())) {
                    Intent intent = new Intent(VideoDetailActivity.this, ArmyDetailActivity.class);
                    intent.putExtra(Config.Extra.toUid, mNewsContent.getAuthorId());
                    intent.putExtra(Config.Extra.id, mNewsContent.getGid());
                    ActivityUtils.startActivity(intent);
                }
            }
        });
        //适配评论
        mCommentListview.addHeaderView(aboutListHead);
        mCommentListview.setFootViewColor(R.color.news_detail_page_bg);

        rlGame = aboutListHead.findViewById(R.id.rlGame);
        if (gameInfo != null) {
            rlGame.setVisibility(View.VISIBLE);
            ImageView ivGameIcon = aboutListHead.findViewById(R.id.ivGameIcon);
            TextView tvGameName = aboutListHead.findViewById(R.id.tvGameName);
            ImageLoadUtils.loadImage(gameInfo.getAppIcon(), ivGameIcon);
            tvGameName.setText(gameInfo.getTitle());
            rlGame.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    StatServiceUtils.event(Config.EventBauduId.knowledgecontent_gameclick, "知识详情游戏点击");
                    Intent intent = new Intent(VideoDetailActivity.this, GameDetailActivity.class);
                    intent.putExtra(Config.Extra.PARAMETER1, gameInfo.getId());
                    intent.putExtra(Config.Extra.PARAMETER2, TypeConstant.SOURCETYPE_NORMAL);
                    startActivity(intent);
                }
            });
        }
        mPlayerJcvideo.setOnVideoListener(new JCVideoPlayer.OnVideoListener() {
            @Override
            public void onProgress(int seconds) {

            }

            @Override
            public void onPlayClick() {
                StatServiceUtils.event(Config.EventBauduId.knowledgecontent_videoclick, "知识详情视频播放");
            }
        });
    }

    /**
     * 配置webview
     */
    private void configWebView() {
        ViewSizeUtils.changeH(mPlayLayout, 315);
        mWebview.setOverScrollMode(View.OVER_SCROLL_NEVER);
        WebSettings settings = mWebview.getSettings();
        // 提高渲染级别
        settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
        // 设置WebView属性，能够执行Javascript脚本
        try {
            settings.setJavaScriptEnabled(true);
        } catch (Exception e) {
            e.printStackTrace();
        }
        settings.setPluginState(WebSettings.PluginState.ON);
        // 关闭缩放
        settings.setBuiltInZoomControls(false);
//        settings.setDisplayZoomControls(false);
        settings.setSupportZoom(false);
        //允许全屏
        settings.setLoadWithOverviewMode(true);
        settings.setUseWideViewPort(true);
//        settings.setPluginsEnabled(true);

        //允许js自动播放
        settings.setJavaScriptCanOpenWindowsAutomatically(true);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            settings.setMixedContentMode(android.webkit.WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);
        }

        mWebview.setWebViewClient(new WebViewClient() {


            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
//                view.loadUrl(url);
                return true;
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                //隐藏加载webview加载控件
                if (mVideoLoad != null && mVideoLoad.getVisibility() == View.VISIBLE) {
                    mVideoLoad.setVisibility(View.GONE);
                }
                if (viewFullScreen != null && viewFullScreen.getVisibility() == View.GONE) {
                    viewFullScreen.setVisibility(View.VISIBLE);
                }
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                //隐藏加载webview加载控件
                if (mVideoLoad != null && mVideoLoad.getVisibility() == View.GONE) {
                    mVideoLoad.setVisibility(View.VISIBLE);
                }
                super.onPageStarted(view, url, favicon);
            }

            @Override
            public void onReceivedSslError(WebView webView, SslErrorHandler sslErrorHandler, SslError sslError) {
                sslErrorHandler.proceed();
            }

            @Override
            public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
                super.onReceivedError(view, errorCode, description, failingUrl);
            }
        });
        mWebview.setWebChromeClient(new WebChromeClient() {
            private Bitmap xdefaltvideo;
            private View xprogressvideo;


            //播放网络视频时全屏会被调用的方法
            @Override
            public void onShowCustomView(View view, IX5WebChromeClient.CustomViewCallback callback) {
                super.onShowCustomView(view, callback);
                if (isVideoLandPort) {
                    return;
                }
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
                mWebview.setVisibility(View.GONE);
                if (myView != null) {
                    callback.onCustomViewHidden();
                    return;
                }

                videoView.addView(view);
                myView = view;
                myCallback = callback;
                videoView.setVisibility(View.VISIBLE);
            }

            public View myView = null;
            public IX5WebChromeClient.CustomViewCallback myCallback = null;

            //视频播放退出全屏会被调用的
            @Override
            public void onHideCustomView() {
                super.onHideCustomView();
                if (myView == null) {
                    return;
                } else {
                    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
                    myView.setVisibility(View.GONE);
                    videoView.removeView(myView);
                    videoView.setVisibility(View.GONE);
                    mWebview.setVisibility(View.VISIBLE);
                    myCallback.onCustomViewHidden();
                    myView = null;
                }
            }

            //视频加载添加默认图标
            @Override
            public Bitmap getDefaultVideoPoster() {
                //Log.i(LOGTAG, "here in on getDefaultVideoPoster");
                if (xdefaltvideo == null) {
                    xdefaltvideo = BitmapFactory.decodeResource(
                            getResources(), R.mipmap.icon);
                }
                return xdefaltvideo;
            }

            //视频加载时进程loading
            @Override
            public View getVideoLoadingProgressView() {
                //Log.i(LOGTAG, "here in on getVideoLoadingPregressView");

                if (xprogressvideo == null) {
                    LayoutInflater inflater = LayoutInflater.from(VideoDetailActivity.this);
                    xprogressvideo = inflater.inflate(R.layout.video_loading_progress, null);
                }
                return xprogressvideo;
            }

            //网页标题
            @Override
            public void onReceivedTitle(WebView view, String title) {
                (VideoDetailActivity.this).setTitle(title);
            }
        });
        mWebview.setDownloadListener(new DownloadListener() {
            @Override
            public void onDownloadStart(String s, String s1, String s2, String s3, long l) {

            }
        });
    }

    private boolean isVideoLandPort = false;


    /**
     * 获取传输的页面数据
     */
    private void getIntentData() {
        Intent intent = getIntent();
        if (intent == null) {
            return;
        }
        newsId = intent.getStringExtra(Config.Extra.PARAMETER1);
        pageSourceType = intent.getStringExtra(Config.Extra.PARAMETER2);
        gameInfo = (NewsEntity.GameInfo) intent.getSerializableExtra(Config.Extra.game);
    }

    /**
     * 加载数据
     */
    private void loadData(final boolean isNoAboutClick) {

        HashMap<String, String> parmsMap = new HashMap<String, String>();
        parmsMap.put("articleId", newsId + "");
        parmsMap.put("sourceType", pageSourceType + "");
        if (UserInforManager.getInstance().isLogin()) {
            parmsMap.put("uid", UserInforManager.getInstance().getUserInfor().getUid());
        }
        HttpListener<DataBean<VideoContent>> httpListener = new HttpListener<DataBean<VideoContent>>() {

            @Override
            public void onStart() {
                if (isNoAboutClick && mNewsLoadView != null) {
                    mNewsLoadView.showLoadPage(null);
                }
            }

            @Override
            public void onError(VolleyError error) {
                if (isNoAboutClick && mNewsLoadView != null) {
                    mNewsLoadView.showErrorPage(AppApplication.getInstance().getString(R.string.neterror_click));
                } else {
                    ToastUtils.showText("服务器连接失败,请稍候再试");
                }
            }

            @Override
            public void onSuccess(DataBean<VideoContent> response) {
                if (response.noError()) {
                    mNewsContent = response.getData();
                    //适配数据
                    adapterUI(isNoAboutClick);
                    //加载评论
                    if (mNewsContent != null) {
                        mCommentListview.startLoadData(mActivity, mNewsContent.getArticleId(), mPageName);
                    }
                } else if (isNoAboutClick) {
                    mNewsLoadView.showErrorPage(response.getMsg());
                } else {
                    ToastUtils.showText(response.getMsg());
                }
            }
        };
        //请求网络
        addPostRequest(URIContant.VIDEO_DETAIL, new TypeToken<DataBean<VideoContent>>() {
        }.getType(), parmsMap, httpListener);


    }

    /**
     * 适配数据
     */
    private void adapterUI(boolean aboutUI) {
        if (mNewsContent == null) {
            if (!aboutUI) {
                //如果是从相关新闻点击的则不展示错误页面
                ToastUtils.makeText(DataBean.getErrorMsg());
                return;
            }
            mNewsLoadView.showErrorPage(DataBean.getErrorMsg());
            return;
        }

        /************* 适配顶部内容页 ***********/
        //加载视频
        if (!TextUtils.isEmpty(mNewsContent.getVideoUrl())
                || !TextUtils.isEmpty(mNewsContent.getVideoCurl())) {
            if (TextUtils.equals(mNewsContent.getUrlStatus(), TypeConstant.NEWS_VIDEO_TYPE1)) {
                //如果网页视频连接为空 就播放云视频
                if (TextUtils.isEmpty(mNewsContent.getVideoUrl())) {
                    //云视频
                    playVideo(aboutUI);
                    if (mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
                        mPlayerWeb.setVisibility(View.GONE);
                        if (mWebview != null) {
                            mWebview.stop();
                        }
                    }
                } else {
//                    //网页视频
                    if (mPlayerJcvideo != null && mPlayerJcvideo.getVisibility() == View.VISIBLE) {
                        mPlayerJcvideo.setVisibility(View.GONE);
                        mPlayerJcvideo.releaseAllVideos();
                    }
                    initWeb();
                    if (mPlayerWeb != null) {
                        mPlayerWeb.setVisibility(View.VISIBLE);
                        if (mWebview != null) {
                            mWebview.loadUrl(mNewsContent.getVideoUrl());
                        }
                    }
                }

            } else if (TextUtils.equals(mNewsContent.getUrlStatus(), TypeConstant.NEWS_VIDEO_TYPE2)) {
                //如果云视频连接为空 就播放网页视频
                if (TextUtils.isEmpty(mNewsContent.getVideoCurl())) {
//                    //网页视频
                    if (mPlayerJcvideo != null && mPlayerJcvideo.getVisibility() == View.VISIBLE) {
                        mPlayerJcvideo.setVisibility(View.GONE);
                        mPlayerJcvideo.releaseAllVideos();
                    }
                    initWeb();
                    if (mPlayerWeb != null) {
                        mPlayerWeb.setVisibility(View.VISIBLE);
                        if (mWebview != null) {
                            mWebview.loadUrl(mNewsContent.getVideoUrl());
                        }
                    }
                } else {
                    //云视频
                    playVideo(aboutUI);
                    if (mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
                        mPlayerWeb.setVisibility(View.GONE);
                        if (mWebview != null) {
                            mWebview.stop();
                        }
                    }
                }

            } else if (TextUtils.equals(mNewsContent.getUrlStatus(), TypeConstant.NEWS_VIDEO_TYPE3)) {
                //优先播放云视频
                if (!TextUtils.isEmpty(mNewsContent.getVideoCurl())) {
                    //播放云视频
                    playVideo(aboutUI);
                    if (mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
                        mPlayerWeb.setVisibility(View.GONE);
                        if (mWebview != null) {
                            mWebview.stop();
                        }
                    }
                } else {
//                    //播放网页视频
                    if (mPlayerJcvideo != null && mPlayerJcvideo.getVisibility() == View.VISIBLE) {
                        mPlayerJcvideo.setVisibility(View.GONE);
                        mPlayerJcvideo.releaseAllVideos();
                    }
                    initWeb();
                    if (mPlayerWeb != null) {
                        mPlayerWeb.setVisibility(View.VISIBLE);
                        if (mWebview != null) {
                            mWebview.loadUrl(mNewsContent.getVideoUrl());
                        }
                    }
                }
            } else {
                ToastUtils.makeText("视频类型无法播放,请升级版本");
                if (aboutUI) {
                    //如果是初始化的话则 直接退出页面
                    onBackPressed();
                }
            }


            VideoAboutAdapter videoAboutAdapter;
            if (mAboutListView != null && mAboutListView.getAdapter() != null) {
                videoAboutAdapter = ((VideoAboutAdapter) mAboutListView.getAdapter());
                videoAboutAdapter.setNewsid(mNewsContent.getArticleId());
                videoAboutAdapter.notifyDataSetChanged();
            }

            if (mSetNumListView != null && mSetNumListView.getAdapter() != null) {
                videoAboutAdapter = ((VideoAboutAdapter) mSetNumListView.getAdapter());
                videoAboutAdapter.setNewsid(mNewsContent.getArticleId());
                videoAboutAdapter.notifyDataSetChanged();
            }
        } else {
            ToastUtils.makeText("没有获取到视频链接,无法播放");
        }


        //设置评论数
        if (this.mCommentSum != null && !"0".equals(mNewsContent.getCommentNum())) {
            this.mCommentSum.setText(mNewsContent.getCommentNum());
            this.mCommentSum.setVisibility(View.VISIBLE);
        } else if (this.mCommentSum != null && this.mCommentSum.getVisibility() == View.VISIBLE) {
            this.mCommentSum.setVisibility(View.GONE);
        }

        //设置分享数
        if (!TextUtils.isEmpty(mNewsContent.getShareNum()) && !"0".equals(mNewsContent.getShareNum())) {
            this.mShareSum.setText(mNewsContent.getShareNum());
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) this.mShareSum.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.width = RelativeLayout.LayoutParams.WRAP_CONTENT;
                layoutParams.height = RelativeLayout.LayoutParams.WRAP_CONTENT;
                this.mShareSum.setLayoutParams(layoutParams);
            }
        }
        LoadImageUtils.getInstance().loadCircleImage(this.mUserHead, mNewsContent.getAuthorHeadPic());
        LoadImageUtils.getInstance().loadImage(this.mUserRankImg, mNewsContent.getAuthorRankIcon());
        ImageLoadUtils.loadImage(mNewsContent.getHonourPic(), ivHonourPic);
        this.tvArmyGroupInfo.setText(mNewsContent.getArmyGroupInfo());
        this.mTitleView.setText(mNewsContent.getArticleTitle());
        this.mTimeView.setText(mNewsContent.getPeriod() + " " + mNewsContent.getArticleTime());
        this.mPlayCount.setText(mNewsContent.getClickNum());
        this.mPraiseView.setText(mNewsContent.getPraiseNum());
        this.mUserName.setText(mNewsContent.getAuthorName());
        this.mUserRankText.setText(mNewsContent.getAuthorRankName());
//        changeAttentionState(mNewsContent.getStatus());
        attView.setTag(mNewsContent);
        attView.setEventValue("视频顶部");
        if (aboutUI) {
            //适配讲堂选集
            if (mNewsContent.getSetVideo() != null && mNewsContent.getSetVideo().size() > 0) {
                findViewById(R.id.rl_setnumlayout).setVisibility(View.VISIBLE);
                findViewById(R.id.morevideo_line).setVisibility(View.VISIBLE);
                this.mSetNumListView.setVisibility(View.VISIBLE);
                this.mMoreVideo.setVisibility(View.VISIBLE);
                this.mSetNumTitle.setText(mNewsContent.getSetNotice());
                this.mSetNumUpdate.setText(mNewsContent.getUpdateNotice());
                VideoAboutAdapter aboutAdapter = new VideoAboutAdapter(mNewsContent.getSetVideo(), this, mNewsContent.getArticleId());
                this.mSetNumListView.setAdapter(aboutAdapter);
                ViewSizeUtils.setListViewHeightBasedOnChildren(mSetNumListView, 80);
                this.mSetNumListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        if (gameInfo != null) {
                            StatServiceUtils.event(Config.EventBauduId.knowledgecontent_morevclick, "知识详情相关视频点击");
                        }
                        if (mNewsContent.getSetVideo() == null) {
                            return;
                        }
                        NewsEntity newsEntity = (NewsEntity) parent.getItemAtPosition(position);
                        if (newsEntity == null) {
                            ToastUtils.makeText("视频已被删除");
                            return;
                        } else {
                            newsId = newsEntity.getArticleId();
                            pageSourceType = TypeConstant.SOURCETYPE_ABOUT;
                        }
                        loadData(false);
                    }
                });
            }


            //适配相关新闻
            if (mAboutListView != null && mNewsContent.getRelatedVideo() != null && mNewsContent.getRelatedVideo().size() > 0) {

                if (mAboutListView.getVisibility() == View.GONE) {
                    findViewById(R.id.il_aboutlist_title).setVisibility(View.VISIBLE);
                    this.mAboutListView.setVisibility(View.VISIBLE);
                }


                List<NewsEntity> relatedVideo = mNewsContent.getRelatedVideo();
                AdConfig.insertAd(relatedVideo, mNewsContent.getTopAdInfo(), 0, 0, null);
                VideoAboutAdapter aboutAdapter = new VideoAboutAdapter(relatedVideo, this
                        , mNewsContent.getArticleId());

                this.mAboutListView.setAdapter(aboutAdapter);
//                ViewSizeUtils.setListViewHeightBasedOnChildren(mAboutListView, 80);
                this.mAboutListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
                    @Override
                    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                        if (gameInfo != null) {
                            StatServiceUtils.event(Config.EventBauduId.knowledgecontent_morevclick, "知识详情相关视频点击");
                        }
                        if (mNewsContent.getRelatedVideo() == null) {
                            return;
                        }
                        NewsEntity newsEntity = (NewsEntity) parent.getItemAtPosition(position);
                        if (newsEntity == null) {
                            ToastUtils.makeText("视频已被删除");
                            return;
                        } else if (TypeConstant.AD.equals(newsEntity.getArticleType())
                                && newsEntity.getNativeAd() != null
                                && AdConfig.AD_TYPE_H5.equals(newsEntity.getNativeAd().getAdType())) {
                            TypeConstant.openTypeDetail(newsEntity, VideoDetailActivity.this, TypeConstant.SOURCETYPE_ABOUT);
                            return;
                        } else {
                            newsId = newsEntity.getArticleId();
                            pageSourceType = TypeConstant.SOURCETYPE_ABOUT;
                        }
                        loadData(false);
                    }
                });
            } else if (mAboutListView != null) {
                //隐藏相关新闻
                findViewById(R.id.il_aboutlist_title).setVisibility(View.GONE);
                this.mAboutListView.setVisibility(View.GONE);
            }
        }

        //查询点赞
        queryZanNews();
        //如果当前有账户登陆则显示账户的收藏状态
        if (UserInforManager.getInstance().isLogin()) {
            //判断是否收藏
            if (mNewsContent.getIsCollect()) {
                this.mCollectView.setImageResource(R.drawable.infor_tabbar_collection_vis);
                this.mCollectView.setTag(true);
            } else {
                this.mCollectView.setImageResource(R.drawable.detail_collect_black_selector);
                this.mCollectView.setTag(false);
            }

        } else if (!aboutUI) {
            //如果是相关新闻的点击则查询收藏
            querySaveNews();
        }

        if (aboutUI) {
            //展示加载成功
            mNewsLoadView.showSuccess();
            //头部背景色隐藏
            ImageView backView = (ImageView) findViewById(R.id.page_head_back_video);
//            backView.setImageResource(R.drawable.left_back_click_white_selector);
            backView.setImageResource(R.drawable.common_backbtn_icon);
            View driver = findViewById(R.id.driver_video);
            driver.setVisibility(View.GONE);
            View titlelayout = findViewById(R.id.video_titlelayout);
            titlelayout.setBackgroundColor(getResources().getColor(R.color.transparent));
        }

    }

    /**
     * 初始化web
     */
    private void initWeb() {
        if (mPlayerWeb != null || mWebview != null) {
            return;
        }
        FrameLayout webContainer = (FrameLayout) findViewById(R.id.webContainer);
        videoView = (FrameLayout) findViewById(R.id.videoView);
        webContainer.removeAllViews();
        webContainer.setVisibility(View.VISIBLE);

        View webPlayerView = getLayoutInflater().inflate(R.layout.view_web, null);
        webContainer.addView(webPlayerView);
        if (webPlayerView != null) {
            mWebview = webPlayerView.findViewById(R.id.video_webview);
            mVideoLoad = webPlayerView.findViewById(R.id.video_load);
            mPlayerWeb = webPlayerView.findViewById(R.id.rl_web_player);
            viewFullScreen = webPlayerView.findViewById(R.id.view_fullscreen);
            videoView = webPlayerView.findViewById(R.id.videoView);
            if (viewFullScreen != null) {
                viewFullScreen.setOnClickListener(this);
            }
            //配置webview
            configWebView();
        }

    }

    /**
     * 播放云视频
     *
     * @param isAboutClick
     */
    private void playVideo(boolean isAboutClick) {
        if (mPlayerJcvideo == null) {
            return;
        }

        mPlayerJcvideo.setShareBean(mNewsContent);
        if (!isAboutClick) {
            //如果从相关视频点击进入的 直接播放接口的Url
            mPlayerJcvideo.setVisibility(View.VISIBLE);

            int height = mPlayerJcvideo.getHeight();
            if (mPlayLayout != null) {
                ViewGroup.LayoutParams layoutParams = mPlayLayout.getLayoutParams();
                if (layoutParams != null && height != 0 && layoutParams.height != height) {
                    layoutParams.height = height;
                    mPlayLayout.requestLayout();
                }
            }

            mPlayerJcvideo.setUp(mNewsContent.getVideoCurl(), JCVideoPlayer.SCREEN_LAYOUT_NORMAL, mNewsContent.getArticleTitle(), mNewsContent.getPlotImg());
            mPlayerJcvideo.startPlay();
            return;
        }
        if (CURRENT_STATE <= JCVideoPlayer.CURRENT_STATE_NORMAL) {
            //直接播放接口的Url
            mPlayerJcvideo.setVisibility(View.VISIBLE);
            mPlayerJcvideo.setUp(mNewsContent.getVideoCurl(), JCVideoPlayer.SCREEN_LAYOUT_NORMAL, mNewsContent.getArticleTitle(), mNewsContent.getPlotImg());
            mPlayerJcvideo.startPlay();
        } else {
            //接着外面的视频播放
            mPlayerJcvideo.setVisibility(View.VISIBLE);
            mPlayerJcvideo.setUp(URL, JCVideoPlayer.SCREEN_LAYOUT_NORMAL, OBJECTS);
            mPlayerJcvideo.setUiWitStateAndScreen(CURRENT_STATE);
            mPlayerJcvideo.initTextureView();
            mPlayerJcvideo.addTextureView();
            JCVideoPlayerManager.setFirstFloor(mPlayerJcvideo);
            //继续播放
            try {
                JCMediaManager.instance().mediaPlayer.start();
            } catch (IllegalStateException e) {
                e.printStackTrace();
            }
            //重力感应监听
            JCScreenSwitchUtils.init(this).start(this, mPlayerJcvideo);
        }


    }

    /**
     * 改变关注状态
     *
     * @param state
     */
//    private void changeAttentionState(String state) {
//        this.attentionBtn.setTag(state);
//        if (TextUtils.equals(state, TypeConstant.ATTENTION_NO)) {
//            this.attentionBtn.setSelected(true);
//            this.attentionText.setText("关注");
//            this.attentionText.setSelected(false);
//            this.attentionImg.getBackground().setLevel(3);
//        } else if (TextUtils.equals(state, TypeConstant.ATTENTION_YES)) {
//            this.attentionBtn.setSelected(false);
//            this.attentionText.setText("已关注");
//            this.attentionText.setSelected(true);
//            this.attentionImg.getBackground().setLevel(5);
//        } else if (TextUtils.equals(state, TypeConstant.ATTENTION_ALL)) {
//            this.attentionBtn.setSelected(false);
//            this.attentionText.setText("互相关注");
//            this.attentionText.setSelected(true);
//            this.attentionImg.getBackground().setLevel(1);
//        }
//    }

    /**
     * 查询当前文文章是否本地收藏
     */
    private void querySaveNews() {
        //如果当前用户已登录则不查询本地
        if (TextUtils.isEmpty(this.newsId) || UserInforManager.getInstance().isLogin()) {
            return;
        }
        boolean issave = CollectUtils.getInstance().querySaveId(this.newsId);
        if (mCollectView != null && issave) {
            this.mCollectView.setImageResource(R.drawable.infor_tabbar_collection_vis);
            this.mCollectView.setTag(true);
        } else if (mCollectView != null) {
            this.mCollectView.setImageResource(R.drawable.detail_collect_black_selector);
            this.mCollectView.setTag(false);
        }

    }

    /**
     * 查询本地的赞
     */
    private void queryZanNews() {
        if (InteractiveUtils.getInstance().theLaudIsContains(this.newsId, true)) {
            mPraiseView.setEnabled(false);
            laudContainer.setTag(true);
        } else {
            mPraiseView.setEnabled(true);
            laudContainer.setTag(mNewsContent);
        }
    }

    /**************
     * 页面初始化 end
     *******************/

    @Override
    public void onClick(View v) {
        if (v == null) {
            return;
        }
        switch (v.getId()) {
            case R.id.error_page://重新加载页面数据
                loadData(true);
                break;
            case R.id.newsDetail_comment_layout://点击评论总数
                swithPage();
                break;
            case R.id.tv_comment://展示评论弹窗
                showCommentDialog();
                break;
            case R.id.fl_laud_container://文章赞
                laudOpration(v);
//                zan();
                break;
            case R.id.iv_collect://文章收藏
                if (com.blankj.utilcode.util.StringUtils.isEmpty(Biz.getInstance().uid())) {
                    UserInforManager.getInstance().toLoginPage(this);
                } else {
                    save();
                }
                break;
            case R.id.iv_share://文章分享
                share();
                break;
            case R.id.iv_report://举报
                reportNews();
                break;
            case R.id.view_fullscreen://全屏
                fullScreen();
                break;

//            case R.id.attention_btn://关注
//                if (v.getTag() == null || mNewsContent == null) {
//                    return;
//                }
//                //关注
//                attention(mNewsContent.getAuthorId() + "", v.getTag().toString());
//                break;
            case R.id.video_username://用户头像
            case R.id.video_usericon:
                Intent intent = new Intent(this, MyHomepageDynamicActivity.class);
                intent.putExtra(Config.Extra.PARAMETER1, mNewsContent.getAuthorId());
                startActivity(intent);
                break;
            case R.id.iv_morevideo_close:
            case R.id.tv_read_all://更多
                showMoreVideo();
                break;

        }
    }

    /**
     * 举报
     */
    private void reportNews() {
        if (reportDialog == null) {
            reportDialog = new ReportDialog(mActivity);
        }
        if (mNewsContent != null) {
            reportDialog.show(mNewsContent.getArticleId(), TypeConstant.PAGE_NEWS, TypeConstant.JUBAO_NEWS);
        }
    }

    /**
     * 点赞动作
     *
     * @param v
     */
    private void laudOpration(View v) {
        if (mNewsContent == null || laudContainer == null) return;
        if (laudContainer.getTag() == null) {
            return;
        }
        InteractiveUtils.getInstance().laud((FrameLayout) v, null);
    }

    /**
     * 展示更多视频
     */
    private void showMoreVideo() {
        if (mNewsContent == null) {
            ToastUtils.makeText("暂无更多视频");
            return;
        }
        if (mMoreVideoLayout == null) {
            mMoreVideoLayout = findViewById(R.id.fl_more_video);
            mMoreVideoLayout.findViewById(R.id.iv_morevideo_close).setOnClickListener(this);
            Handler handler = new Handler() {
                public void handleMessage(android.os.Message msg) {
                    //打开视频
                    newsId = msg.obj.toString();
                    loadData(false);
                }
            };
            VideoShowFragment videoShowFragment = new VideoShowFragment();
            Bundle bundle = new Bundle();
            bundle.putString(Config.Extra.PARAMETER1, mNewsContent.getCateId());
            videoShowFragment.setArguments(bundle);
            videoShowFragment.setHandler(handler);
            FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
            ft.replace(R.id.fl_more_video, videoShowFragment);
            ft.commit();
        }
        TextView textView = (TextView) mMoreVideoLayout.findViewById(R.id.tv_morevideo_setnum_update);
        textView.setText(mNewsContent.getSetNotice());
        if (mMoreVideoLayout != null && mMoreVideoLayout.getVisibility() == View.GONE) {
            mMoreVideoLayout.setVisibility(View.VISIBLE);
            Animation animation = AnimationUtils.loadAnimation(this, R.anim.dialog_enter_anim);
            mMoreVideoLayout.startAnimation(animation);
        } else {
            Animation animation = AnimationUtils.loadAnimation(this, R.anim.dialog_exit_anim);
            mMoreVideoLayout.startAnimation(animation);
            mMoreVideoLayout.setVisibility(View.GONE);
        }

    }

    /**
     * 全屏按钮
     */
    private void fullScreen() {
        if (islandport) {
            //设置横屏
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        } else {
            //设置竖屏
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }

    }

    /**
     * 分享
     */
    private void share() {
        if (mShareUtils == null) {
            mShareUtils = new AppShareUtils(this);
        }
        mShareUtils.showShareDialog(this.mNewsContent, TypeConstant.PAGE_VIDEO_DETAIL);
    }


    /**
     * 收藏
     */
    private void save() {
        if (mNewsContent == null || this.mCollectView == null) {
            ToastUtils.makeText(R.drawable.handle_fail, "操作失败");
            return;
        }
        Object isSave = this.mCollectView.getTag();//获取是否收藏标识
        if (isSave == null || !((boolean) isSave)) {
            //如果没有收藏 则 进行收藏操作
            boolean b = CollectUtils.getInstance().saveNews(mNewsContent.getArticleId());
            if (b) {
                ToastUtils.makeText(R.drawable.infor_pop_collection_yes, "收藏成功");
                this.mCollectView.setImageResource(R.drawable.infor_tabbar_collection_vis);
                this.mCollectView.setTag(true);
            } else {
                ToastUtils.makeText(R.drawable.handle_fail, "操作失败");
            }
        } else {
            //如果已收藏 则 进行取消操作
            boolean b = CollectUtils.getInstance().deleteSaveNews(mNewsContent.getArticleId());
            if (b) {
                ToastUtils.makeText(R.drawable.infor_pop_collection_cancel, "取消收藏");
                this.mCollectView.setImageResource(R.drawable.detail_collect_black_selector);
                this.mCollectView.setTag(false);
            } else {
                ToastUtils.makeText(R.drawable.handle_fail, "操作失败");
            }
        }

    }

    /**
     * 点赞
     */
    private void zan() {
        if (mPraiseView == null || mNewsContent == null) {
            ToastUtils.makeText(R.drawable.handle_fail, "点赞失败");
            return;
        }
        Object b = mPraiseView.getTag();
        int num = 0;
        ParamMap parmsMap = new ParamMap();
        try {
            if (b != null && ((boolean) b)) {
                //如果已经点过赞 则取消点赞
                mPraiseView.setSelected(false);
                mPraiseView.setTag(false);
                num = Integer.valueOf(mPraiseView.getText().toString()) - 1;
                //取消赞参数
                parmsMap.putEncode("operateType", "1");

                initZanView(false);
            } else {
                //如果没有点赞 则进行点赞
                mPraiseView.setSelected(true);
                mPraiseView.setTag(true);
                num = Integer.valueOf(mPraiseView.getText().toString()) + 1;
                //点赞 参数
                parmsMap.putEncode("operateType", "0");
                initZanView(true);
            }
        } catch (Resources.NotFoundException e) {
            e.printStackTrace();
        }
        if (num >= 0) {
            mPraiseView.setText(num + "");
        }
        //请求点赞网络操作
        if (UserInforManager.getInstance().isLogin()) {
            parmsMap.putEncode("uid", UserInforManager.getInstance().getUserInfor().getUid());
        } else {
            parmsMap.putEncode("uid", "");
        }
        parmsMap.putEncode("type", "0");
        parmsMap.putEncode("articleId", mNewsContent.getArticleId());
        parmsMap.putEncode("toUid", "");
        parmsMap.putEncode("commentId", "");
        parmsMap.putEncode("parentCmtId", "");
        HttpUtils.ParmsMapMD5(parmsMap);
        HttpListener<DataBean> httpListener = new HttpListener<DataBean>() {
            @Override
            public void onError(VolleyError error) {
            }

            @Override
            public void onSuccess(DataBean response) {
            }
        };

        //请求网络
        addPostRequest(URIContant.NEWS_ZAN, new TypeToken<DataBean>() {
        }.getType(), parmsMap, httpListener);
    }

    /* 展示评论框 */
    private void showCommentDialog() {
        if (mCommentListener == null) {
            mCommentListener = new CommentListener() {
                @Override
                public void commentStart() {

                }

                @Override
                public void commentFail(VolleyError volley) {

                }

                @Override
                public void commentSuccess(NewsComment newsComment) {
                    LogUtils.e("NewsComment "+newsComment.getHonourPic());
                    LogUtils.e("NewsComment "+newsComment.getArmyGroupInfo());
                    //更新页面
                    if (mCommentListview == null) {
                        return;
                    }
                    mCommentListview.addComment(newsComment);
                    if (mCommentSum != null) {
                        int num = StringUtils.toInt(mCommentSum.getText().toString(), 0);
                        mCommentSum.setText("" + (++num));
                        if (mCommentSum.getVisibility() == View.GONE) {
                            mCommentSum.setVisibility(View.VISIBLE);
                        }
                    }
                }
            };
        }
        CommentUtils.getInstance().showDialog(this, mPageName, newsId, null, mCommentListener);
    }

    /**
     * 切换页面
     */
    private void swithPage() {

        if (mCommentListview == null) {
            return;
        }
        if (mCommentListview.getLastVisiblePosition() == 0) {
            mCommentListview.setSelection(1);
        } else {
            mCommentListview.setSelection(0);
        }
    }

    @Override
    public void onBackPressed() {
        if (JCVideoPlayer.backPress()) {
            //判断是否有视频全屏
            return;
        }
        if (!islandport) {
            //设置竖屏
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            return;
        }
        if (mMoreVideoLayout != null && mMoreVideoLayout.getVisibility() == View.VISIBLE) {
            showMoreVideo();
            return;
        }
        super.onBackPressed();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == Config.ResultCode.REQUESTCODE_1
                && resultCode == RESULT_OK && data != null) {
            if (mCommentListview != null) {
                mCommentListview.notifyZanData(data.getBooleanExtra(Config.Extra.PARAMETER1, false));
            }
        } else {
            //设置友盟回调
            try {
                if (data != null) {
                    UMShareAPI.get(this).onActivityResult(requestCode, resultCode, data);
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


    }

    @Override
    protected void onResume() {
        super.onResume();
        //继续播放视频
        if (mWebview != null && mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
            //如果当前是网页播放器则继续播放视频
            mWebview.play();
        } else {
            //如果当前是本地播放器则 不做任何操作
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if (mWebview != null && mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
            //如果当前是网页播放器则 暂停视频
            mWebview.stop();
        } else {
            //如果当前是本地播放器则 暂停视频
            JCVideoPlayer.releaseAllVideos();
        }
    }

    @Override
    protected void onDestroy() {
        DialogUtils.getInstance().dismissCustomDialog();
        if (mWebview != null) {
            mWebview.destroy();
        }
        CURRENT_STATE = -1;
        super.onDestroy();
    }


    /**
     * 当横竖屏切换时会调用该方法
     *
     * @author
     */
    @Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            islandport = false;
            isVideoLandPort = true;
            setFullScreen();
        } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            islandport = true;
            isVideoLandPort = false;
            quitFullScreen();
        }

    }

    /**
     * 设置全屏
     */
    private void setFullScreen() {
        if (mPlayerWeb == null || mPlayerWeb.getVisibility() == View.GONE) {
            return;
        }
        if (mBottomLayoutView != null) {
            mBottomLayoutView.setVisibility(View.GONE);
        }
        if (mCommentListview != null) {
            mCommentListview.setVisibility(View.GONE);
        }
        if (mPlayLayout != null) {
            RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mPlayLayout.getLayoutParams();
            layoutParams.height = RelativeLayout.LayoutParams.MATCH_PARENT;
            layoutParams.width = RelativeLayout.LayoutParams.MATCH_PARENT;

        }

    }


    /**
     * 退出全屏
     */
    private void quitFullScreen() {
        if (mPlayerWeb != null && mPlayerWeb.getVisibility() == View.VISIBLE) {
            if (mBottomLayoutView != null && mBottomLayoutView.getVisibility() == View.GONE) {
                mBottomLayoutView.setVisibility(View.VISIBLE);
            }
            if (mCommentListview != null && mCommentListview.getVisibility() == View.GONE) {
                mCommentListview.setVisibility(View.VISIBLE);
            }
            if (mPlayLayout != null) {
                ViewSizeUtils.changeH(mPlayLayout, 315);
            }
        }
    }

    /**
     * 更改 本地 zan 表的数据
     *
     * @param insertOrDel true：插入，false：删除
     */
    private void initZanView(boolean insertOrDel) {
        if (insertOrDel) {//插入
            NewsDBUtil.getInstance().changeNewsZAN(true, mNewsContent.getArticleId(), true);
        } else {//删除
            NewsDBUtil.getInstance().changeNewsZAN(false, mNewsContent.getArticleId(), true);
        }
    }

    @Override
    public void onPositiveClick() {
//        DialogUtils.getInstance().dismissCustomDialog();
    }

    @Override
    public void onNegativeClick() {
//        DialogUtils.getInstance().dismissCustomDialog();
    }


    /**
     * 打开视频详情页面(该方法只是用于视频列表的点击)
     *
     * @param context
     * @param articleId
     * @param pageSourceType
     * @param state
     * @param url
     * @param obj
     */
    public static void openDetailActivity(Context context, String articleId, String pageSourceType,
                                          int state, String url, Object... obj) {
//        URL = url;
//        OBJECTS = obj;
//        CURRENT_STATE = state;
        Intent intent = new Intent(context, VideoDetailActivity.class);
        intent.putExtra(Config.Extra.PARAMETER1, articleId);
        intent.putExtra(Config.Extra.PARAMETER2, pageSourceType);
        context.startActivity(intent);
    }
}
